import {defineConfig}         from 'vite'
import vue                    from '@vitejs/plugin-vue'
import vueJsx                 from '@vitejs/plugin-vue-jsx';
import prismjsPlugin          from "vite-plugin-prismjs";
import Components             from 'unplugin-vue-components/vite';
import { NaiveUiResolver }    from 'unplugin-vue-components/resolvers';
// const {configCompressPlugin} = require("./src/plugins/compress")

// https://vitejs.dev/config/
export default defineConfig({
    server:{
        port: 32100,
        strictPort: true
    },
    plugins: [
        prismjsPlugin({
            languages: 'all'
        }),
        vue(),
        vueJsx(),
        // 按需引入NaiveUi且自动创建组件声明
        Components({
            dts: true,
            resolvers: [NaiveUiResolver()],
        }),
        // configCompressPlugin("brotli", true)
    ],
    css: {
        preprocessorOptions: {
            less: {
                modifyVars: {},
                javascriptEnabled: true,
                additionalData: `@import "src/styles/var.less";`,
            },
        },
    },
    build: {
        target: 'es2015',
        cssTarget: 'chrome65',
        outDir: "./dist",
        terserOptions: {
            compress: {
                keep_infinity: true,
                drop_console: true,
            },
        },
        brotliSize: false,
        chunkSizeWarningLimit: 2000,
    }
})
